{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "16873712-1a56-4f10-90de-634875f65ab0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "from promptify import Prompter,OpenAI,Pipeline\n",
    "from pprint import pprint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "01b2cb21-7032-4933-8c8f-cfaee66ecc76",
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import Markdown, display\n",
    "from IPython.display import display, HTML"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "dccda836-c445-4497-ae0f-3ff4d1a984f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "api_key = \"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "847dfada-d5cc-47ef-9fe7-52ed95378822",
   "metadata": {},
   "outputs": [],
   "source": [
    "model=OpenAI(api_key)\n",
    "prompter = Prompter('qa_gen.jinja')\n",
    "pipe = Pipeline(prompter,model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f9b2a4bf-ab41-4362-aa7e-f04b664ca086",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "In a world of over 7.9 billion people, approximately 4.66 billion individuals are active internet users, representing a staggering 59% of the global population. The exponential growth of digitalization is evident in the fact that there are an estimated 5.22 billion unique mobile users worldwide. Social media platforms continue to dominate the online landscape, with Facebook boasting a user base of around 2.8 billion, followed closely by YouTube with over 2.3 billion users. E-commerce has also seen remarkable growth, with global online retail sales surpassing $4.2 trillion in 2023, marking a significant increase from the previous year. Additionally, the rapid adoption of cryptocurrencies is reshaping financial landscapes, with Bitcoin leading the pack at a market capitalization exceeding $1.5 trillion, showcasing the evolving trends in digital assets.\n"
     ]
    }
   ],
   "source": [
    "sent    =  \"In a world of over 7.9 billion people, approximately 4.66 billion individuals are active internet users, representing a staggering 59% of the global population. The exponential growth of digitalization is evident in the fact that there are an estimated 5.22 billion unique mobile users worldwide. Social media platforms continue to dominate the online landscape, with Facebook boasting a user base of around 2.8 billion, followed closely by YouTube with over 2.3 billion users. E-commerce has also seen remarkable growth, with global online retail sales surpassing $4.2 trillion in 2023, marking a significant increase from the previous year. Additionally, the rapid adoption of cryptocurrencies is reshaping financial landscapes, with Bitcoin leading the pack at a market capitalization exceeding $1.5 trillion, showcasing the evolving trends in digital assets.\"\n",
    "print(sent)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1bcd707b-d5c7-48b0-bda9-7b9de0079e14",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00,  1.42s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'text': \"[{'Q': 'How many active internet users are there out of the global population?', 'A': 'Approximately 4.66 billion individuals are active internet users out of the global population.'}]\", 'usage': {'prompt_tokens': 290, 'completion_tokens': 41, 'total_tokens': 331}, 'parsed': {'status': 'completed', 'object_type': <class 'list'>, 'data': {'completion': [{'Q': 'How many active internet users are there out of the global population?', 'A': 'Approximately 4.66 billion individuals are active internet users out of the global population.'}], 'suggestions': []}}}]\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "result = pipe.fit(sent,\n",
    "                domain = 'medical',\n",
    "                total_questions=1,\n",
    "                max_QA_tokens=1\n",
    "                )\n",
    "print(result)"
   ]
  }
,
  
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d02ad4bd-dabe-4c47-82b2-62e9f98525c5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
